package com.FrameWork.Common;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;

public class CommonFunction
{

	public static AlertDialog ShowNetWorkErrorDialog(Context context)
	{
		return ShowDialog(context, "网络出现异常，请重试");

	}

	public static AlertDialog ShowNetWorkErrorDialogWithFinish(Context context)
	{
		return ShowDialogWithFinish(context, "网络出现异常，请重试");

	}

	public static AlertDialog ShowDialog(Context context, String Message)
	{

		AlertDialog dialog = new AlertDialog.Builder(context).setCustomTitle(null)
		.setMessage(Message)
		.setPositiveButton("确定",
				null)
				.create();
		dialog.show();
		return dialog;

	}

	public static AlertDialog ShowDialogWithFinish(final Context context,
			String Message)
	{
		AlertDialog dialog = new AlertDialog.Builder(context).setCustomTitle(null)
		.setMessage(Message)
		.setPositiveButton("确定",
				new DialogInterface.OnClickListener()
		{

			public void onClick(DialogInterface dialog,
					int which)
			{
				// TODO
				// Auto-generated
				// method
				// stub
				((Activity) context).finish();
			}
		})
		.create();
		//
		dialog.show();
		return dialog;

	}

	public static ProgressDialog ShowProgressDialog(Context context,
			String Message)
	{
		ProgressDialog dialog = ProgressDialog.show(context, null, Message,true);
		dialog.setCancelable(true);
		return dialog;
	}
	
	public static ProgressDialog ShowProgressDialog(Context context,
			int  resID, boolean Cancelable)
	{
		ProgressDialog dialog = ProgressDialog.show(context, null, context.getResources().getString(resID),true);
		dialog.setCancelable(Cancelable);
		return dialog;
	}
}
